package cn.edu.scau.cmi.youbaiquan.controller;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.youbaiquan.adapter.AdapterOfObject;
import cn.edu.scau.cmi.youbaiquan.adapter.CHNAdapterOfClass;
import cn.edu.scau.cmi.youbaiquan.adapter.CHNPowerAdaptee;
import cn.edu.scau.cmi.youbaiquan.adapter.USAdapterOfClass;
import cn.edu.scau.cmi.youbaiquan.adapter.USPowerAdaptee;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;

public class AdapterController {

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private Button class_US;

    @FXML
    private Button class_CHN;

    @FXML
    private TextArea class_output;

    @FXML
    private Button object_US;

    @FXML
    private Button object_CHN;

    @FXML
    private TextArea object_output;

    @FXML
    void initialize() {
        assert class_US != null : "fx:id=\"class_US\" was not injected: check your FXML file 'AdapterUI.fxml'.";
        assert class_CHN != null : "fx:id=\"class_CHN\" was not injected: check your FXML file 'AdapterUI.fxml'.";
        assert class_output != null : "fx:id=\"class_output\" was not injected: check your FXML file 'AdapterUI.fxml'.";
        assert object_US != null : "fx:id=\"object_US\" was not injected: check your FXML file 'AdapterUI.fxml'.";
        assert object_CHN != null : "fx:id=\"object_CHN\" was not injected: check your FXML file 'AdapterUI.fxml'.";
        assert object_output != null : "fx:id=\"object_output\" was not injected: check your FXML file 'AdapterUI.fxml'.";

    }
    
    
    @FXML
    void show_object_CHN() {
    	AdapterOfObject adapterOfObject = new AdapterOfObject(new CHNPowerAdaptee());
    	object_output.appendText(adapterOfObject.outputAC5V() + "\n-> ");
    }
    
    @FXML
    void show_object_US() {
    	AdapterOfObject adapterOfObject = new AdapterOfObject(new USPowerAdaptee());
    	object_output.appendText(adapterOfObject.outputAC5V() + "\n-> ");
    }
    
    @FXML
    void show_class_CHN() {
    	CHNAdapterOfClass adapterOfClass = new CHNAdapterOfClass();
    	class_output.appendText(adapterOfClass.outputAC5V() + "\n-> ");
    }
    
    @FXML
    void show_class_US() {
    	USAdapterOfClass adapterOfClass = new USAdapterOfClass();
    	class_output.appendText(adapterOfClass.outputAC5V() + "\n-> ");
    }
    
}
